-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE PaRegistrarPago
	@IdCliente int,
	@MontoPagado numeric(10,2),
	@FechaDePago date,
	@TipoPago char,
	@DiasEfectivos int

AS
BEGIN
	SET NOCOUNT ON;
	BEGIN TRY
		
		BEGIN TRAN
			
			INSERT INTO [dbo].[PagosXCliente]
           ([IdUsuario]
           ,[Tipo]
           ,[FechaPago]
           ,[MontoPagado]
           ,[DiasEfectivos])
     VALUES
           (@IdCliente
           ,@TipoPago
           ,@FechaDePago
           ,@MontoPagado
           ,@DiasEfectivos)
		
		COMMIT TRAN

	END TRY
	BEGIN CATCH
		
		DECLARE @ErrorMessage NVARCHAR(4000);
		DECLARE @ErrorSeverity INT;
		DECLARE @ErrorState INT;

		SELECT 
			@ErrorMessage = ERROR_MESSAGE(),
			@ErrorSeverity = ERROR_SEVERITY(),
			@ErrorState = ERROR_STATE();

		RAISERROR (@ErrorMessage, -- Message text.
				   @ErrorSeverity, -- Severity.
				   @ErrorState -- State.
				   );
		
		IF(@@TRANCOUNT>0)
			ROLLBACK TRAN
		
	END CATCH;
END


